<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div class="input-num"></div>
        <button @click="sub">
            -
        </button>
        <span> {{number}} </span>
        <button @click="add">
            +
        </button>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el:"#app",
            data:{
                message:"hello,black man",
                number:1,
            },
            methods: {
                add:function(){
                    if(this.number<10){
                        this.number++;
                    }
                    else{
                        alert("你想把我买空嘛？");
                    }
                },
                sub:function(){
                    if(this.number>0){
                        this.number--;
                    }
                    else{
                        alert("不买你就退出去喽~");
                    }
                }
            },


        })
    </script>

</body>
</html>